import request from '@/config/axios'

export interface EnterpriseBillSummaryVO {
  id: number
  batchNo: string
  companyId: number
  companyName: string
  entrustStartDate: string
  entrustEndDate: string
  serviceDurationMonths: number
  totalAmount: number
  invoiceStatus: string
  invoiceInfoId: number
  collectionInfoId: number
  invoiceInfoDetail: string
  collectionInfoDetail: string
  createTime: Date
}

export interface EnterpriseBillSummaryPageReqVO extends PageParam {
  companyName?: string
  entrustStartDate?: string
  entrustEndDate?: string
  invoiceStatus?: string
  batchNo?: string
  createTime?: Date[]
}

export interface EnterpriseBillSummaryGenerateReqVO {
  companyIds?: number[]
  billStartDate: string
  billEndDate: string
}

export interface EnterpriseBillSummarySaveReqVO {
  id?: number
  companyId: number
  entrustStartDate: string
  entrustEndDate: string
  serviceDurationMonths: number
  totalAmount: number
  invoiceStatus: string
  invoiceInfoId?: number
  collectionInfoId?: number
}

export interface AccountingCompaniesInvoiceVO {
  id: number
  companyId: number
  invoiceName: string
  address: string
  bankName: string
  taxNumber: string
  phone: string
  bankAccount: string
  infoType: number
  createTime: string
}

// 查询企业账单汇总分页
export const getEnterpriseBillSummaryPageApi = (params: EnterpriseBillSummaryPageReqVO) => {
  return request.get({ url: '/oa/enterprise-bill-summary/page', params })
}

// 查询企业账单汇总详情
export const getEnterpriseBillSummaryApi = (id: number) => {
  return request.get({ url: `/oa/enterprise-bill-summary/get?id=${id}` })
}

// 生成企业账单汇总
export const generateEnterpriseBillSummaryApi = (data: EnterpriseBillSummaryGenerateReqVO) => {
  return request.post({ url: '/oa/enterprise-bill-summary/generate', data })
}

// 保存企业账单汇总
export const saveEnterpriseBillSummaryApi = (data: EnterpriseBillSummarySaveReqVO) => {
  return request.post({ url: '/oa/enterprise-bill-summary/save', data })
}

// 删除企业账单汇总
export const deleteEnterpriseBillSummaryApi = (id: number) => {
  return request.delete({ url: `/oa/enterprise-bill-summary/delete?id=${id}` })
}

// 批量更新开票状态
export const updateInvoiceStatusApi = (ids: number[], invoiceStatus: string) => {
  return request.post({ 
    url: '/oa/enterprise-bill-summary/update-invoice-status',
    data: { ids, invoiceStatus }
  })
}

// 导出企业账单汇总 Excel
export const exportEnterpriseBillSummaryApi = (params: EnterpriseBillSummaryPageReqVO) => {
  return request.download({ 
    url: '/oa/enterprise-bill-summary/export-excel', 
    params
  })
}

// 获取开票信息
export const getInvoiceInfoApi = (invoiceInfoId: number) => {
  return request.get({ url: `/oa/enterprise-bill-summary/get-invoice-info?invoiceInfoId=${invoiceInfoId}` })
}

// 获取收款信息
export const getCollectionInfoApi = (collectionInfoId: number) => {
  return request.get({ url: `/oa/enterprise-bill-summary/get-collection-info?collectionInfoId=${collectionInfoId}` })
} 